﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using Kotonoha.Server.Dictionaries;

namespace Kotonoha.Server.UI.Converters {
    class MeaningsConverter : ValueConverterWithDesignerSupport {

        protected override object ConvertToCore(object value, Type type, object parameter, CultureInfo culture) {
            IEnumerable<Meaning> meanings = value as IEnumerable<Meaning>;

            if (meanings == null) {
                return "";
            }

            return meanings
                .Select(meaning => meaning.Aggregate((s1, s2) => string.Format("{0},{1}", s1, s2)))
                .Aggregate((s1, s2) => string.Format("{0}/{1}", s1, s2));
        }

        protected override object ConvertFromCore(object value, Type type, object parameter, CultureInfo culture) {
            throw new NotImplementedException();
        }
    }
}
